﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using SharePointExplorer.UserControls;
using SharePointExplorer.SharePoint;
using Microsoft.Kinect;
using SharePointExplorer.Classes;
using FluidKit.Controls;

namespace SharePointExplorer
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        App CurrentApplication = (App)Application.Current;
        public KinectSensor kinectSensor { get; set; }
        NavigationManager nm = new NavigationManager();
        public MainWindow()
        {
            InitializeComponent();
            CurrentApplication.MainWindowInstance = this;
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            KinectHelper kinectHelper = new KinectHelper();
            nm.LoadFirstScreen();
        }

        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {

        }

        private void ExitButton_Click(object sender, RoutedEventArgs e)
        {
            Environment.Exit(0);
        }

        private void BackButton_Click(object sender, RoutedEventArgs e)
        {
            //nm.NavigateContent(NavigationManager.controlStack.LastOrDefault(), NavigationManager.controlStack[NavigationManager.controlStack.Count - 1], Direction.RightToLeft);
            UserControl cntrl1 = (UserControl)NextPanel.Children[0];
            UserControl cntrl2 = (UserControl)CurrentPanel.Children[0];

            if (cntrl2.Tag.ToString() == "DashboardSubItems")
                nm.NavigateContent((UserControl)NextPanel.Children[0], new DashboardSubItems(CurrentApplication.CurrentList), Direction.LeftToRight);
            else
            {
                nm.NavigateContent((UserControl)NextPanel.Children[0], (UserControl)CurrentPanel.Children[0], Direction.LeftToRight);
                SharePointExplorer.Classes.KinectHelper.TogglePostureDetectedHandler(false);
            }
            
            ((App)Application.Current).MainWindowInstance.backButton.Visibility = Visibility.Collapsed;
            txtCurrentScreen.Text = ((UserControl)NextPanel.Children[0]).Tag.ToString();
            
        }

        private void AudioButton_Click(object sender, RoutedEventArgs e)
        {

        }

        private void DeactivateButton_Click(object sender, RoutedEventArgs e)
        {
            SharePointUtils.ClearFlags();
            DeactivateButton.IsEnabled = false;
            imgDeactivate.Source = new BitmapImage(new Uri("/SharePointExplorer;component/Images/Deactivate_disabled.png", UriKind.Relative));
        }

        private void HomeButton_Click(object sender, RoutedEventArgs e)
        {
            nm.NavigateContent((UserControl)NextPanel.Children[0], new Dashboard(), Direction.LeftToRight);
        }

        private void StartOverButton_Click(object sender, RoutedEventArgs e)
        {
            nm.NavigateContent((UserControl)NextPanel.Children[0], new SharePointLocator(), Direction.LeftToRight);
        }

        public void UpdateSiteTitle()
        {
            txtCurrentURL.Text = SharePointHelper.SiteTitle;
        }

       
    }
}
